<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8" />
	<title>新增脚本</title>
</head>
<body>
<header th:replace="header::html"></header>
<div class="x-body">
	<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form">
				<input id="hiddenId" type="hidden" th:value="${lemonScripts.id}" name="id" />
				<div class="layui-form-item">
					<div class="layui-form-item">
						<label for="path" class="layui-form-label"><span class="x-red">*</span>路径</label>
						<div class="layui-input-inline">
							<input th:value="${lemonScripts.path}" class="layui-input" placeholder="/usr/local/cmd.sh" type="text" name="path" id="path" lay-verify="required" />
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-form-item">
							<label class="layui-form-label">类型：</label>
							<div class="layui-input-inline" >
								<input type="radio" name="type" value="1" title="windows" {lemonScripts.type=="1"?"checked":""}>
								<input type="radio" name="type" value="2" title="linux" {lemonScripts.type=="2"?"checked":""}>
							</div>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-form-item">
							<div class="layui-form-item">
								<label class="layui-form-label">状态：</label>
								<div class="layui-input-inline" >
									<input type="radio" name="status" value="0" title="禁用" {lemonScripts.status=="0"?"checked":""}>
									<input type="radio" name="status" value="1" title="启用" {lemonScripts.status=="1"?"checked":""}>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label"></label>
								<button class="layui-btn" lay-filter="add" lay-submit=""> <i class="iconfont"></i>立即提交 </button>
							</div>
						</div>
					</div>
				</div>
			</form>
			<script type="text/javascript">
				layui.use(['form', 'layer'], function () {
					$ = layui.jquery;
					var form = layui.form
							, layer = layui.layer
					//监听提交
					form.on('submit(add)', function (data) {
						$.ajax({
							url: "/lemonScripts/saveOrUpdate",
							type: "POST",
							data: data.field,
							dataType: 'json',
							success: function (result) {
								if (result.code == 500 || result.code == 5000100 || result.code == 5000101 || result.code == 5000102) {
									layer.alert(result.msg);
								} else {
									layer.alert("设置成功", {icon: 6}, function () {
										xadmin.close();
										xadmin.father_reload();
									});
								}
							}
						});
						return false;
					});
					initSelectType();
				});
			</script>
		</div>
	</div>
</div>
</body>
</html>
